package com.loveprogrammer.eternity.model.mission;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

/**
 * @version 1.0.0
 * @description:
 * @author: eric
 * @date: 2022-09-15 16:58
 **/
public enum MissionState {

    cannotAccept(0, "不能接受"),
    canAccept(1, "可以接受"),
    doTasking(2, "进行中"),
    completeTask(3, "已完成"),
    finishTask(4, "已结束");

    private int code;

    private String desc;

    MissionState(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static MissionState getByCode(int code){
        Optional<MissionState> optional =
                Arrays.stream(MissionState.values())
                        .filter(v -> Objects.equals(v.getCode(), code))
                        .findFirst();

        return optional.orElse(MissionState.cannotAccept);
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }
}
